﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using BISPOS.Repository;
using DevExpress.XtraEditors.Controls;
namespace BISPOS
{
    public class UIHelper
    {
        ProductRepository productRepository = new ProductRepository();
        public void FillProductGroups(DevExpress.XtraEditors.ImageComboBoxEdit comboBox, int? selectedValue)
        {
            ImageComboBoxItemCollection collection = comboBox.Properties.Items;
            foreach (var productGroup in productRepository.AllProductGroups())
            {
                collection.Add(new ImageComboBoxItem
                {
                    Value = productGroup.Id,
                    Description = productGroup.Name
                });
              
            }
            if (selectedValue.HasValue)
                comboBox.SelectedItem = collection.GetItem(selectedValue.Value);
            else
                comboBox.SelectedIndex = -1;
        }
    }
}
